org.eclipse.vtp.framework.engine.runtime
Class RuntimeUtils

java.lang.Object
  extended by org.eclipse.vtp.framework.engine.runtime.RuntimeUtils

public final class RuntimeUtils
extends java.lang.Object

Utilities used by the various runtime components.

Author:
Lonnie Pryor

Constructor Summary
RuntimeUtils()
           
 
Method Summary
static java.lang.Object createInstance(java.lang.Class type)
          Creates a new instance of the specified class via Class.newInstance().
static java.lang.Object createInstance(java.lang.reflect.Constructor constructor, java.lang.Object[] arguments)
          Creates a new instance of the specified class via the supplied constructor.
static java.lang.String getQualifiedIdentifier(java.lang.String identifier, java.lang.String qualifier)
          Generates a unique string from the supplied qualifier and identifier.
static java.lang.String getXMLIdentifier(org.w3c.dom.Element element)
          Generates a unique string from the supplied element's name space URI and tag name.
static void listTypeHierarchy(java.lang.Class type, java.util.Set types)
          Adds the specified type and all its super-types to the supplied set.
static void setProperty(java.lang.Object instance, java.lang.reflect.Method mutator, java.lang.Object value)
          Sets a property on an object instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuntimeUtils

public RuntimeUtils()
Method Detail

getQualifiedIdentifier

public static java.lang.String getQualifiedIdentifier(java.lang.String identifier,
                                                      java.lang.String qualifier)
                                               throws java.lang.NullPointerException
Generates a unique string from the supplied qualifier and identifier.

Parameters:
identifier - The identifier to be qualified.
qualifier - The qualifier of the identifier.
Returns:
A unique string from the supplied name space and identifier.
Throws:
java.lang.NullPointerException - If supplied identifier is null.
java.lang.NullPointerException - If supplied qualifier is null.

getXMLIdentifier

public static java.lang.String getXMLIdentifier(org.w3c.dom.Element element)
                                         throws java.lang.NullPointerException
Generates a unique string from the supplied element's name space URI and tag name.

Parameters:
element - The element to generate the identifier for.
Returns:
A unique string from the supplied element's name space URI and tag name.
Throws:
java.lang.NullPointerException - If supplied element is null.

listTypeHierarchy

public static void listTypeHierarchy(java.lang.Class type,
                                     java.util.Set types)
                              throws java.lang.NullPointerException
Adds the specified type and all its super-types to the supplied set.

Parameters:
type - The type to list the hierarchy of.
types - The set to populate with classes.
Throws:
java.lang.NullPointerException - If the supplied set is null.

createInstance

public static java.lang.Object createInstance(java.lang.Class type)
                                       throws java.lang.IllegalStateException,
                                              java.lang.NullPointerException
Creates a new instance of the specified class via Class.newInstance().

Parameters:
type - The type of object to create.
Returns:
The new object instance.
Throws:
java.lang.IllegalStateException - If the object creation fails.
java.lang.NullPointerException - If the supplied type is null.

createInstance

public static java.lang.Object createInstance(java.lang.reflect.Constructor constructor,
                                              java.lang.Object[] arguments)
                                       throws java.lang.IllegalStateException,
                                              java.lang.NullPointerException
Creates a new instance of the specified class via the supplied constructor.

Parameters:
constructor - The constructor to create the object with.
arguments - The arguments to satisfy the constructor with.
Returns:
The new object instance.
Throws:
java.lang.IllegalArgumentException - If the supplied constructor argument array has more or less elements than the specified constructor does arguments.
java.lang.IllegalStateException - If the object creation fails.
java.lang.NullPointerException - If the supplied constructor is null.
java.lang.NullPointerException - If the supplied constructor argument array or any of its elements are null.

setProperty

public static void setProperty(java.lang.Object instance,
                               java.lang.reflect.Method mutator,
                               java.lang.Object value)
                        throws java.lang.IllegalStateException,
                               java.lang.NullPointerException
Sets a property on an object instance.

Parameters:
instance - The instance to set the property on.
mutator - The property mutator method to invoke.
value - The value to set the property to.
Throws:
java.lang.IllegalArgumentException - If the supplied mutator does not take exactly one argument.
java.lang.IllegalStateException - If the object creation fails.
java.lang.NullPointerException - If the supplied instance is null.
java.lang.NullPointerException - If the supplied mutator is null.